<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of statmap_anova</title>
  <meta name="keywords" content="statmap_anova">
  <meta name="description" content="Use the anova to select features that vary between conditions">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html . -->
<h1>statmap_anova
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Use the anova to select features that vary between conditions</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [subj] = statmap_anova(subj,data_patname,regsname,selname,new_map_patname,extra_arg) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Use the anova to select features that vary between conditions

 [SUBJ] = STATMAP_ANOVA(SUBJ,DATA_PATNAME,REGSNAME,NEW_MAP_PATNAME);

 Adds the following objects:
 - statmap pattern object

 Updates the subject structure by creating a new pattern,
 NEW_MAP_PATNAME, that contains a vector of P-values from the ANOVA.

 Uses all the conditions in REGSNAME. If you only want to use a
 subset of them, create a new regressors object with only those
 conditions

 Only uses those TRs labelled with a 1 in the SELNAME selector,
 and where there's an active condition in the REGSNAME regressors matrix

 There should be functionality in here for return the F values as
 well (e.g. an optional argument 'MAP_TYPE' that defaults to 'p') xxx

 The EXTRA_ARG is completely useless here. All statmaps that can
 be used by FEATURE_SELECT have to take it though</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="add_created.html" class="code" title="function [subj] = add_created(subj,objtype,objname,new_creat)">add_created</a>	Makes it easier to add the object-creation data easier</li><li><a href="add_history.html" class="code" title="function [subj] = add_history(subj,objtype,objname,hist_str,displayme)">add_history</a>	Adds HIST_STR to OBJNAME's history field.</li><li><a href="check_1ofn_regressors.html" class="code" title="function [isbool isrest isoveractive] = check_1ofn_regressors(regressors)">check_1ofn_regressors</a>	Tells you about your regressors matrix</li><li><a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>	Returns the MAT field of the object</li><li><a href="get_objfield.html" class="code" title="function [val] = get_objfield(subj,objtype,objname,fieldname)">get_objfield</a>	Retrieves a field from an object</li><li><a href="init_object.html" class="code" title="function [subj] = init_object(subj,objtype,new_objname);">init_object</a>	Add a new empty object</li><li><a href="set_mat.html" class="code" title="function [subj] = set_mat(subj,objtype,objname,newmat,varargin)">set_mat</a>	Updates the MAT contents of an object</li><li><a href="set_objfield.html" class="code" title="function [subj] = set_objfield(subj,objtype,objname,fieldname,newval,varargin)">set_objfield</a>	Replace or add a field to an object</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="peek_feature_select.html" class="code" title="function [subj] = peek_feature_select(subj,data_patname,regsname,selname,varargin)">peek_feature_select</a>	Just like PEEK_FEATURE_SELECT, except that it peeks</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="#_sub1" class="code">function [p] = statmap_anova_logic(pat,regs)</a></li><li><a href="#_sub2" class="code">function [] = sanity_check(pat,regs,sel)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [subj] = statmap_anova(subj,data_patname,regsname,selname,new_map_patname,extra_arg)</a>
0002 
0003 <span class="comment">% Use the anova to select features that vary between conditions</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% [SUBJ] = STATMAP_ANOVA(SUBJ,DATA_PATNAME,REGSNAME,NEW_MAP_PATNAME);</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% Adds the following objects:</span>
0008 <span class="comment">% - statmap pattern object</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% Updates the subject structure by creating a new pattern,</span>
0011 <span class="comment">% NEW_MAP_PATNAME, that contains a vector of P-values from the ANOVA.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">% Uses all the conditions in REGSNAME. If you only want to use a</span>
0014 <span class="comment">% subset of them, create a new regressors object with only those</span>
0015 <span class="comment">% conditions</span>
0016 <span class="comment">%</span>
0017 <span class="comment">% Only uses those TRs labelled with a 1 in the SELNAME selector,</span>
0018 <span class="comment">% and where there's an active condition in the REGSNAME regressors matrix</span>
0019 <span class="comment">%</span>
0020 <span class="comment">% There should be functionality in here for return the F values as</span>
0021 <span class="comment">% well (e.g. an optional argument 'MAP_TYPE' that defaults to 'p') xxx</span>
0022 <span class="comment">%</span>
0023 <span class="comment">% The EXTRA_ARG is completely useless here. All statmaps that can</span>
0024 <span class="comment">% be used by FEATURE_SELECT have to take it though</span>
0025 
0026 <span class="comment">% This is part of the Princeton MVPA toolbox, released under the</span>
0027 <span class="comment">% GPL. See http://www.csbmb.princeton.edu/mvpa for more</span>
0028 <span class="comment">% information.</span>
0029 
0030 
0031 <span class="keyword">if</span> ~isempty(extra_arg)
0032   warning(<span class="string">'Ignoring extra_arg'</span>);
0033 <span class="keyword">end</span>
0034 
0035 pat  = <a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>(subj,<span class="string">'pattern'</span>,data_patname);
0036 regs = <a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>(subj,<span class="string">'regressors'</span>,regsname);
0037 sel  = <a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>(subj,<span class="string">'selector'</span>,selname);
0038 
0039 <a href="#_sub2" class="code" title="subfunction [] = sanity_check(pat,regs,sel)">sanity_check</a>(pat,regs,sel);
0040 
0041 TRs_to_use = find(sel==1);
0042 
0043 pat   = pat(:,TRs_to_use);
0044 regs = regs(:,TRs_to_use);
0045 
0046 <span class="comment">% Do all the hard work inside STATMAP_ANOVA_LOGIC</span>
0047 p = <a href="#_sub1" class="code" title="subfunction [p] = statmap_anova_logic(pat,regs)">statmap_anova_logic</a>(pat,regs);
0048 
0049 <span class="comment">% Now create a new pattern object to house the statmap with the p</span>
0050 <span class="comment">% values in it</span>
0051 subj = <a href="init_object.html" class="code" title="function [subj] = init_object(subj,objtype,new_objname);">init_object</a>(subj,<span class="string">'pattern'</span>,new_map_patname);
0052 subj = <a href="set_mat.html" class="code" title="function [subj] = set_mat(subj,objtype,objname,newmat,varargin)">set_mat</a>(subj,<span class="string">'pattern'</span>,new_map_patname,p);
0053 
0054 <span class="comment">% Every pattern needs to know which mask it is masked by</span>
0055 masked_by = <a href="get_objfield.html" class="code" title="function [val] = get_objfield(subj,objtype,objname,fieldname)">get_objfield</a>(subj,<span class="string">'pattern'</span>,data_patname,<span class="string">'masked_by'</span>);
0056 subj = <a href="set_objfield.html" class="code" title="function [subj] = set_objfield(subj,objtype,objname,fieldname,newval,varargin)">set_objfield</a>(subj,<span class="string">'pattern'</span>,new_map_patname,<span class="string">'masked_by'</span>,masked_by);
0057 
0058 hist = sprintf(<span class="string">'Created by statmap_anova'</span>,data_patname);
0059 subj = <a href="add_history.html" class="code" title="function [subj] = add_history(subj,objtype,objname,hist_str,displayme)">add_history</a>(subj,<span class="string">'pattern'</span>,new_map_patname,hist);
0060 
0061 created.function = <span class="string">'statmap_anova'</span>;
0062 created.data_patname = data_patname;
0063 created.regsname = regsname;
0064 created.selname = selname;
0065 created.extra_arg = extra_arg;
0066 created.new_map_patname = new_map_patname;
0067 subj = <a href="add_created.html" class="code" title="function [subj] = add_created(subj,objtype,objname,new_creat)">add_created</a>(subj,<span class="string">'pattern'</span>,new_map_patname,created);
0068 
0069 
0070 
0071 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0072 <a name="_sub1" href="#_subfunctions" class="code">function [p] = statmap_anova_logic(pat,regs)</a>
0073 
0074 <span class="comment">% -- building of vector conds and vector groups</span>
0075 
0076 nVox    = size(pat,1);
0077 nConds  = size(regs,1); 
0078 groups  = [];
0079 dataIdx = [];
0080 
0081 <span class="keyword">for</span> c=1:nConds
0082   theseIdx = find(regs(c,:)==1);
0083   dataIdx  =[dataIdx,theseIdx];
0084   groups   =[groups,repmat(c,1,length(theseIdx))];
0085 <span class="keyword">end</span>
0086 
0087 <span class="comment">% run the anova and save the p's</span>
0088 p=zeros(nVox,1);
0089  
0090 <span class="keyword">for</span> j=1:nVox
0091   <span class="keyword">if</span> mod(j,10000) == 0
0092     <span class="comment">% disp( sprintf('anova on %i of %i',j,nVox) );</span>
0093     fprintf(<span class="string">'.'</span>);
0094   <span class="keyword">end</span>
0095   p(j) = anova1(pat(j,dataIdx'),groups,<span class="string">'off'</span>);
0096 <span class="keyword">end</span>   
0097 
0098 
0099 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0100 <a name="_sub2" href="#_subfunctions" class="code">function [] = sanity_check(pat,regs,sel)</a>
0101 
0102 <span class="comment">% Check that your regressors are in the correct 1-of-n form</span>
0103 [isbool isrest isoveractive] = <a href="check_1ofn_regressors.html" class="code" title="function [isbool isrest isoveractive] = check_1ofn_regressors(regressors)">check_1ofn_regressors</a>(regs);
0104 <span class="keyword">if</span> ~isbool | isoveractive
0105   error(<span class="string">'Your regressors aren''t in 1-of-n form'</span>);
0106 <span class="keyword">end</span>
0107 
0108 <span class="keyword">if</span> size(pat,2) ~= size(regs,2)
0109   error(<span class="string">'Wrong number of timepoints'</span>);
0110 <span class="keyword">end</span>
0111 
0112 <span class="keyword">if</span> size(pat,2) ~= size(sel,2)
0113   error(<span class="string">'Wrong number of timepoints'</span>);
0114 <span class="keyword">end</span>
0115 
0116 <span class="keyword">if</span> ~isrow(sel)
0117   error(<span class="string">'Your selector needs to be a row vector'</span>);
0118 <span class="keyword">end</span>
0119 
0120 <span class="keyword">if</span> max(sel)&gt;2 | min(sel)&lt;0
0121   disp(<span class="string">'These selectors don''t look like cross-validation selectors'</span>);
0122   error(<span class="string">'Are you feeding in your runs by accident?'</span>);
0123 <span class="keyword">end</span>
0124 
0125 <span class="keyword">if</span> ~length(find(regs)) | ~length(find(sel))
0126   error(<span class="string">'There''s nothing for the ANOVA to run on'</span>);
0127 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Tue 06-Sep-2005 22:11:31 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>